﻿package mortal.game.scene3D.player.entity
{
    import mortal.game.scene3D.player.info.*;

    public class RoleModelPlayer extends UserModelPlayer
    {
        protected var _entityInfo:EntityInfo;

        public function RoleModelPlayer()
        {
            return;
        }// end function

        public function set entityInfo(param1:EntityInfo) : void
        {
            this.removeEntityInfoEvent();
            this._entityInfo = param1;
            this.updateIsShowEffect(this._entityInfo.isWeaponItem, this._entityInfo.isClothesItem, this._entityInfo.isWingItem);
            this.updateInfo(this._entityInfo.entityInfo.career, this._entityInfo.entityInfo.sex, this._entityInfo.clothes, this._entityInfo.weapon, this._entityInfo.hair, this._entityInfo.wing, this._entityInfo.entityInfo.VIP, this._entityInfo.isHideWing);
            this.addEntityInfoEvent();
            return;
        }// end function

        protected function addEntityInfoEvent() : void
        {
            this._entityInfo.addEventListener(EntityInfoEventName.UpdateClothes, this.onUpdateClothes);
            this._entityInfo.addEventListener(EntityInfoEventName.UpdateWeapon, this.onUpdateWeapon);
            this._entityInfo.addEventListener(EntityInfoEventName.UpdateSex, this.onUpdateSex);
            this._entityInfo.addEventListener(EntityInfoEventName.UpdateCareer, this.onUpdateCareer);
            this._entityInfo.addEventListener(EntityInfoEventName.updateHair, this.onUpdateHair);
            this._entityInfo.addEventListener(EntityInfoEventName.updateWing, this.onUpdateWing);
            return;
        }// end function

        protected function removeEntityInfoEvent() : void
        {
            if (this._entityInfo)
            {
                this._entityInfo.removeEventListener(EntityInfoEventName.UpdateClothes, this.onUpdateClothes);
                this._entityInfo.removeEventListener(EntityInfoEventName.UpdateWeapon, this.onUpdateWeapon);
                this._entityInfo.removeEventListener(EntityInfoEventName.UpdateSex, this.onUpdateSex);
                this._entityInfo.removeEventListener(EntityInfoEventName.UpdateCareer, this.onUpdateCareer);
                this._entityInfo.removeEventListener(EntityInfoEventName.updateHair, this.onUpdateHair);
                this._entityInfo.removeEventListener(EntityInfoEventName.updateWing, this.onUpdateWing);
            }
            return;
        }// end function

        protected function onUpdateClothes(event:EntityInfoEvent) : void
        {
            this.clothes = this._entityInfo.clothes;
            loadClothes();
            return;
        }// end function

        protected function onUpdateWeapon(event:EntityInfoEvent) : void
        {
            this.weapon = this._entityInfo.weapon;
            loadWeapon();
            return;
        }// end function

        protected function onUpdateSex(event:EntityInfoEvent) : void
        {
            this.sex = this._entityInfo.entityInfo.sex;
            loadClothes();
            loadWeapon();
            return;
        }// end function

        protected function onUpdateCareer(event:EntityInfoEvent) : void
        {
            this.weapon = this._entityInfo.entityInfo.career;
            loadClothes();
            loadWeapon();
            return;
        }// end function

        protected function onUpdateHair(event:EntityInfoEvent) : void
        {
            this.hair = this._entityInfo.hair;
            loadHair();
            return;
        }// end function

        protected function onUpdateWing(event:EntityInfoEvent) : void
        {
            this.wing = this._entityInfo.wing;
            this.isHideWing = this._entityInfo.isHideWing;
            loadWing();
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            super.dispose(param1);
            this.removeEntityInfoEvent();
            this._entityInfo = null;
            return;
        }// end function

    }
}
